<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">
    <h:head>
        <title>Facelet Title</title>
    </h:head>
    <h:body>
        <ui:composition template="../../templates/master.xhtml">
            <ui:define name="content">
                <p:dataTable value="#{complaintsController.complaints}" paginator="true" rows="10"
                             paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}" 
                             var="c" rowsPerPageTemplate="5,10,15" id="complaintTable" lazy="true">
                    <p:column headerText="ID">
                        <h:outputText value="#{c.id}"/>
                    </p:column>
                    <p:column sortBy="#{c.title}" filterBy="#{c.title}" headerText="Name">
                        <h:outputText  value="#{c.title}"/><br/>
                       
                    </p:column>
                    <p:column filterBy="#{c.categoryName}" headerText="Category">
                        <p:commandLink value="#{c.categoryID.name}" action="#{categoriesController.prepareView(c.categoryID.id)}" icon="ui-icon-search"/>
                    </p:column>
                    <p:column headerText="Department" filterBy="#{c.departmentName}">
                        <p:commandLink value="#{c.departmentID.name}" action="#{departmentsController.prepareView(c.departmentID.id)}">
                        </p:commandLink>
                    </p:column>
                    <p:column headerText="Last Updated">
                        <h:outputText class="lastedUpdate" value="#{c.lastUpdated}">
                            <f:convertDateTime pattern="dd-MM-yyyy 'at' HH:mm:ss"/>
                        </h:outputText>
                    </p:column>
                    <p:column headerText="#">
                        <p:commandButton immediate="true" ajax="false" icon="ui-icon-search" id="ViewDetailButton" action="#{complaintsController.prepareView()}">
                            <f:setPropertyActionListener target="#{complaintsController.selected}" value="#{c}"/>
                        </p:commandButton>
                    </p:column>

                </p:dataTable>
            </ui:define>
        </ui:composition>
    </h:body>
</html>

